<template>
	<view>
		<view class="title">
			<text v-for="(item,index) in state" class="color">{{item.name}}</text>
		</view>
		<view class="list" v-for="(item,index) in demo"  :key='index'>
			<view class="content">
				<view class="" @click="details(item.id)">
					<view class="top">
						<text>{{item.content}}</text>
					</view>
					<view class="center">
						<view class="img">
							<image v-for="item in item.images" :src="item.url" mode=""></image>
						</view>
					  	<view class="font">
							<text>{{item.address}}</text>
							<text>{{item.typename}}</text>
						</view>
					</view>
				</view>
				<view class="bottom">
					<text class="text">20121-10-3  10:20</text>
					<view class="btn">
						<view class="">
							{{item.statename}}
						</view>
						<view class="" @click="delet(item.id)">
							撤销
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {Repairs} from '../../static/api/apis.js'
	export default {
		data() {
			return {
				demo:[],
				state:[]
			}
		},
		methods: {
			// 详情
			details(id){
				console.log(id)
				uni.navigateTo({
					url:'details?id='+id,
				})
			},
			async list(){
				let res = await Repairs.List()
				console.log(res)
				if(res.errCode==10000){
					this.demo = res.data.list
				}
			},
			async State(){
				let res = await Repairs.State()
				console.log(res)
				if(res.errCode==10000){
					this.state = res.data.list
				}
			},
			// 删除
			async delet(id){
				let res = await Repairs.delete({id:id})
				console.log(res)
				if(res.errCode==10000){
					uni.showToast({
						title:'撤销成功',
						icon:'success'
					})
					this.list()
				}
			}
		},
		onLoad() {
			this.list()
			this.State()
		}
	}
</script>

<style lang="less" scoped>
@import url("../../static/css/Repairs/list.less");
</style>
